import React, { useRef, useState, useEffect } from 'react';
import { Button, Form, Input, Spin } from 'antd';
import moment from 'moment';
// import { planViewSearch, resetCache, activityViewSearch } from '@/services/operate';
import { v4 as uuidV4 } from 'uuid';

import type { HandleMoveArg } from './calendar-header';
import CalendarHeader from './calendar-header';
// import ModelOutput from './model-output';
import CalendarBody from './calendar-body';
import styles from './style.less';

const mock1 = [
  {
    id: 55,
    brandName: 'KFC',
    planName: '测试执行不生效计划',
    activityIds: 'TEST20230914005S',
    startTime: '2024-08-07 00:00:00',
    endTime: '2024-12-31 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 7,
    cgusercodesuffix: '941,243,339,812,698,653,065',
    planStatus: 1,
    alertStatus: 1,
    createdBy: 'ben',
    updatedBy: 'lipan',
    createdAt: '2024-08-05 10:25:46',
    updatedAt: '2024-08-31 11:41:35',
    viewStatus: 2,
    startTimeLocalDate: '2024-09-01',
    endTimeLocalDate: '2024-09-02',
    rankDatas: [null],
  },
  {
    id: 55,
    brandName: 'KFC',
    planName: '测试执行不生效计划',
    activityIds: 'TEST20230914005S',
    startTime: '2024-08-07 00:00:00',
    endTime: '2024-12-31 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 7,
    cgusercodesuffix: '941,243,339,812,698,653,065',
    planStatus: 1,
    alertStatus: 1,
    createdBy: 'ben',
    updatedBy: 'lipan',
    createdAt: '2024-08-05 10:25:46',
    updatedAt: '2024-08-31 11:41:35',
    viewStatus: 2,
    startTimeLocalDate: '2024-09-02',
    endTimeLocalDate: '2024-09-09',
    rankDatas: [null, null, null, null, null, null, null],
  },
  {
    id: 55,
    brandName: 'KFC',
    planName: '测试执行不生效计划',
    activityIds: 'TEST20230914005S',
    startTime: '2024-08-07 00:00:00',
    endTime: '2024-12-31 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 7,
    cgusercodesuffix: '941,243,339,812,698,653,065',
    planStatus: 1,
    alertStatus: 1,
    createdBy: 'ben',
    updatedBy: 'lipan',
    createdAt: '2024-08-05 10:25:46',
    updatedAt: '2024-08-31 11:41:35',
    viewStatus: 2,
    startTimeLocalDate: '2024-09-09',
    endTimeLocalDate: '2024-09-16',
    rankDatas: [
      null,
      null,
      null,
      null,
      {
        planId: 55,
        rankDate: '2024-09-13',
        incrementalSales: 1249795.2487,
        incrementalSalesPercent: 0.0259,
        hasData: 1,
      },
      {
        planId: 55,
        rankDate: '2024-09-14',
        incrementalSales: 758461.4572,
        incrementalSalesPercent: 0.022,
        hasData: 1,
      },
      {
        planId: 55,
        rankDate: '2024-09-15',
        incrementalSales: 254330.736,
        incrementalSalesPercent: 0.0046,
        hasData: 1,
      },
    ],
  },
  {
    id: 55,
    brandName: 'KFC',
    planName: '测试执行不生效计划',
    activityIds: 'TEST20230914005S',
    startTime: '2024-08-07 00:00:00',
    endTime: '2024-12-31 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 7,
    cgusercodesuffix: '941,243,339,812,698,653,065',
    planStatus: 1,
    alertStatus: 1,
    createdBy: 'ben',
    updatedBy: 'lipan',
    createdAt: '2024-08-05 10:25:46',
    updatedAt: '2024-08-31 11:41:35',
    viewStatus: 2,
    startTimeLocalDate: '2024-09-16',
    endTimeLocalDate: '2024-09-23',
    rankDatas: [null, null, null, null, null, null, null],
  },
  {
    id: 55,
    brandName: 'KFC',
    planName: '测试执行不生效计划',
    activityIds: 'TEST20230914005S',
    startTime: '2024-08-07 00:00:00',
    endTime: '2024-12-31 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 7,
    cgusercodesuffix: '941,243,339,812,698,653,065',
    planStatus: 1,
    alertStatus: 1,
    createdBy: 'ben',
    updatedBy: 'lipan',
    createdAt: '2024-08-05 10:25:46',
    updatedAt: '2024-08-31 11:41:35',
    viewStatus: 2,
    startTimeLocalDate: '2024-09-23',
    endTimeLocalDate: '2024-09-30',
    rankDatas: [null, null, null, null, null, null, null],
  },
  {
    id: 55,
    brandName: 'KFC',
    planName: '测试执行不生效计划',
    activityIds: 'TEST20230914005S',
    startTime: '2024-08-07 00:00:00',
    endTime: '2024-12-31 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 7,
    cgusercodesuffix: '941,243,339,812,698,653,065',
    planStatus: 1,
    alertStatus: 1,
    createdBy: 'ben',
    updatedBy: 'lipan',
    createdAt: '2024-08-05 10:25:46',
    updatedAt: '2024-08-31 11:41:35',
    viewStatus: 2,
    startTimeLocalDate: '2024-09-30',
    endTimeLocalDate: '2024-10-01',
    rankDatas: [null],
  },
  {
    id: 56,
    brandName: 'KFC',
    planName: '测试计划0805',
    activityIds: 'KFCSZ202404420,KFCSZ202404417',
    startTime: '2024-08-05 00:00:00',
    endTime: '2024-12-31 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 3,
    cgusercodesuffix: '367,848,201',
    planStatus: 1,
    alertStatus: 1,
    createdBy: 'ben',
    updatedBy: 'ben',
    createdAt: '2024-08-05 10:27:06',
    updatedAt: '2024-08-30 11:41:38',
    viewStatus: 1,
    startTimeLocalDate: '2024-09-01',
    endTimeLocalDate: '2024-09-02',
    rankDatas: [null],
  },
  {
    id: 56,
    brandName: 'KFC',
    planName: '测试计划0805',
    activityIds: 'KFCSZ202404420,KFCSZ202404417',
    startTime: '2024-08-05 00:00:00',
    endTime: '2024-12-31 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 3,
    cgusercodesuffix: '367,848,201',
    planStatus: 1,
    alertStatus: 1,
    createdBy: 'ben',
    updatedBy: 'ben',
    createdAt: '2024-08-05 10:27:06',
    updatedAt: '2024-08-30 11:41:38',
    viewStatus: 1,
    startTimeLocalDate: '2024-09-02',
    endTimeLocalDate: '2024-09-09',
    rankDatas: [null, null, null, null, null, null, null],
  },
  {
    id: 56,
    brandName: 'KFC',
    planName: '测试计划0805',
    activityIds: 'KFCSZ202404420,KFCSZ202404417',
    startTime: '2024-08-05 00:00:00',
    endTime: '2024-12-31 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 3,
    cgusercodesuffix: '367,848,201',
    planStatus: 1,
    alertStatus: 1,
    createdBy: 'ben',
    updatedBy: 'ben',
    createdAt: '2024-08-05 10:27:06',
    updatedAt: '2024-08-30 11:41:38',
    viewStatus: 1,
    startTimeLocalDate: '2024-09-09',
    endTimeLocalDate: '2024-09-16',
    rankDatas: [null, null, null, null, null, null, null],
  },
  {
    id: 56,
    brandName: 'KFC',
    planName: '测试计划0805',
    activityIds: 'KFCSZ202404420,KFCSZ202404417',
    startTime: '2024-08-05 00:00:00',
    endTime: '2024-12-31 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 3,
    cgusercodesuffix: '367,848,201',
    planStatus: 1,
    alertStatus: 1,
    createdBy: 'ben',
    updatedBy: 'ben',
    createdAt: '2024-08-05 10:27:06',
    updatedAt: '2024-08-30 11:41:38',
    viewStatus: 1,
    startTimeLocalDate: '2024-09-16',
    endTimeLocalDate: '2024-09-23',
    rankDatas: [null, null, null, null, null, null, null],
  },
  {
    id: 56,
    brandName: 'KFC',
    planName: '测试计划0805',
    activityIds: 'KFCSZ202404420,KFCSZ202404417',
    startTime: '2024-08-05 00:00:00',
    endTime: '2024-12-31 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 3,
    cgusercodesuffix: '367,848,201',
    planStatus: 1,
    alertStatus: 1,
    createdBy: 'ben',
    updatedBy: 'ben',
    createdAt: '2024-08-05 10:27:06',
    updatedAt: '2024-08-30 11:41:38',
    viewStatus: 1,
    startTimeLocalDate: '2024-09-23',
    endTimeLocalDate: '2024-09-30',
    rankDatas: [null, null, null, null, null, null, null],
  },
  {
    id: 56,
    brandName: 'KFC',
    planName: '测试计划0805',
    activityIds: 'KFCSZ202404420,KFCSZ202404417',
    startTime: '2024-08-05 00:00:00',
    endTime: '2024-12-31 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 3,
    cgusercodesuffix: '367,848,201',
    planStatus: 1,
    alertStatus: 1,
    createdBy: 'ben',
    updatedBy: 'ben',
    createdAt: '2024-08-05 10:27:06',
    updatedAt: '2024-08-30 11:41:38',
    viewStatus: 1,
    startTimeLocalDate: '2024-09-30',
    endTimeLocalDate: '2024-10-01',
    rankDatas: [null],
  },
  {
    id: 22,
    brandName: 'KFC',
    planName: '测试未来生效',
    activityIds: 'TEST20230914001S',
    startTime: '2024-05-31 00:00:00',
    endTime: '2024-12-31 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 3,
    cgusercodesuffix: '73,88,43',
    planStatus: 2,
    alertStatus: 0,
    createdBy: 'lipan',
    updatedBy: 'lipan',
    createdAt: '2024-05-30 18:27:55',
    updatedAt: '2024-05-30 18:27:55',
    viewStatus: 1,
    startTimeLocalDate: '2024-09-01',
    endTimeLocalDate: '2024-09-02',
    rankDatas: [null],
  },
  {
    id: 22,
    brandName: 'KFC',
    planName: '测试未来生效',
    activityIds: 'TEST20230914001S',
    startTime: '2024-05-31 00:00:00',
    endTime: '2024-12-31 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 3,
    cgusercodesuffix: '73,88,43',
    planStatus: 2,
    alertStatus: 0,
    createdBy: 'lipan',
    updatedBy: 'lipan',
    createdAt: '2024-05-30 18:27:55',
    updatedAt: '2024-05-30 18:27:55',
    viewStatus: 1,
    startTimeLocalDate: '2024-09-02',
    endTimeLocalDate: '2024-09-09',
    rankDatas: [null, null, null, null, null, null, null],
  },
  {
    id: 22,
    brandName: 'KFC',
    planName: '测试未来生效',
    activityIds: 'TEST20230914001S',
    startTime: '2024-05-31 00:00:00',
    endTime: '2024-12-31 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 3,
    cgusercodesuffix: '73,88,43',
    planStatus: 2,
    alertStatus: 0,
    createdBy: 'lipan',
    updatedBy: 'lipan',
    createdAt: '2024-05-30 18:27:55',
    updatedAt: '2024-05-30 18:27:55',
    viewStatus: 1,
    startTimeLocalDate: '2024-09-09',
    endTimeLocalDate: '2024-09-16',
    rankDatas: [null, null, null, null, null, null, null],
  },
  {
    id: 22,
    brandName: 'KFC',
    planName: '测试未来生效',
    activityIds: 'TEST20230914001S',
    startTime: '2024-05-31 00:00:00',
    endTime: '2024-12-31 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 3,
    cgusercodesuffix: '73,88,43',
    planStatus: 2,
    alertStatus: 0,
    createdBy: 'lipan',
    updatedBy: 'lipan',
    createdAt: '2024-05-30 18:27:55',
    updatedAt: '2024-05-30 18:27:55',
    viewStatus: 1,
    startTimeLocalDate: '2024-09-16',
    endTimeLocalDate: '2024-09-23',
    rankDatas: [null, null, null, null, null, null, null],
  },
  {
    id: 22,
    brandName: 'KFC',
    planName: '测试未来生效',
    activityIds: 'TEST20230914001S',
    startTime: '2024-05-31 00:00:00',
    endTime: '2024-12-31 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 3,
    cgusercodesuffix: '73,88,43',
    planStatus: 2,
    alertStatus: 0,
    createdBy: 'lipan',
    updatedBy: 'lipan',
    createdAt: '2024-05-30 18:27:55',
    updatedAt: '2024-05-30 18:27:55',
    viewStatus: 1,
    startTimeLocalDate: '2024-09-23',
    endTimeLocalDate: '2024-09-30',
    rankDatas: [null, null, null, null, null, null, null],
  },
  {
    id: 22,
    brandName: 'KFC',
    planName: '测试未来生效',
    activityIds: 'TEST20230914001S',
    startTime: '2024-05-31 00:00:00',
    endTime: '2024-12-31 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 3,
    cgusercodesuffix: '73,88,43',
    planStatus: 2,
    alertStatus: 0,
    createdBy: 'lipan',
    updatedBy: 'lipan',
    createdAt: '2024-05-30 18:27:55',
    updatedAt: '2024-05-30 18:27:55',
    viewStatus: 1,
    startTimeLocalDate: '2024-09-30',
    endTimeLocalDate: '2024-10-01',
    rankDatas: [null],
  },
  {
    id: 21,
    brandName: 'KFC',
    planName: '测试053001',
    activityIds: 'SZKFC2405048,SZKFC2405049,SZKFC2405050',
    startTime: '2024-07-01 00:00:00',
    endTime: '2024-12-02 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 1,
    cgusercodesuffix: '14',
    planStatus: 2,
    alertStatus: 0,
    createdBy: 'lipan',
    updatedBy: 'lipan',
    createdAt: '2024-05-30 17:54:57',
    updatedAt: '2024-05-30 18:08:07',
    viewStatus: 1,
    startTimeLocalDate: '2024-09-01',
    endTimeLocalDate: '2024-09-02',
    rankDatas: [null],
  },
  {
    id: 21,
    brandName: 'KFC',
    planName: '测试053001',
    activityIds: 'SZKFC2405048,SZKFC2405049,SZKFC2405050',
    startTime: '2024-07-01 00:00:00',
    endTime: '2024-12-02 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 1,
    cgusercodesuffix: '14',
    planStatus: 2,
    alertStatus: 0,
    createdBy: 'lipan',
    updatedBy: 'lipan',
    createdAt: '2024-05-30 17:54:57',
    updatedAt: '2024-05-30 18:08:07',
    viewStatus: 1,
    startTimeLocalDate: '2024-09-02',
    endTimeLocalDate: '2024-09-09',
    rankDatas: [null, null, null, null, null, null, null],
  },
  {
    id: 21,
    brandName: 'KFC',
    planName: '测试053001',
    activityIds: 'SZKFC2405048,SZKFC2405049,SZKFC2405050',
    startTime: '2024-07-01 00:00:00',
    endTime: '2024-12-02 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 1,
    cgusercodesuffix: '14',
    planStatus: 2,
    alertStatus: 0,
    createdBy: 'lipan',
    updatedBy: 'lipan',
    createdAt: '2024-05-30 17:54:57',
    updatedAt: '2024-05-30 18:08:07',
    viewStatus: 1,
    startTimeLocalDate: '2024-09-09',
    endTimeLocalDate: '2024-09-16',
    rankDatas: [null, null, null, null, null, null, null],
  },
  {
    id: 21,
    brandName: 'KFC',
    planName: '测试053001',
    activityIds: 'SZKFC2405048,SZKFC2405049,SZKFC2405050',
    startTime: '2024-07-01 00:00:00',
    endTime: '2024-12-02 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 1,
    cgusercodesuffix: '14',
    planStatus: 2,
    alertStatus: 0,
    createdBy: 'lipan',
    updatedBy: 'lipan',
    createdAt: '2024-05-30 17:54:57',
    updatedAt: '2024-05-30 18:08:07',
    viewStatus: 1,
    startTimeLocalDate: '2024-09-16',
    endTimeLocalDate: '2024-09-23',
    rankDatas: [null, null, null, null, null, null, null],
  },
  {
    id: 21,
    brandName: 'KFC',
    planName: '测试053001',
    activityIds: 'SZKFC2405048,SZKFC2405049,SZKFC2405050',
    startTime: '2024-07-01 00:00:00',
    endTime: '2024-12-02 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 1,
    cgusercodesuffix: '14',
    planStatus: 2,
    alertStatus: 0,
    createdBy: 'lipan',
    updatedBy: 'lipan',
    createdAt: '2024-05-30 17:54:57',
    updatedAt: '2024-05-30 18:08:07',
    viewStatus: 1,
    startTimeLocalDate: '2024-09-23',
    endTimeLocalDate: '2024-09-30',
    rankDatas: [null, null, null, null, null, null, null],
  },
  {
    id: 21,
    brandName: 'KFC',
    planName: '测试053001',
    activityIds: 'SZKFC2405048,SZKFC2405049,SZKFC2405050',
    startTime: '2024-07-01 00:00:00',
    endTime: '2024-12-02 23:59:59',
    controlGroupType: 1,
    controlGroupPercent: 1,
    cgusercodesuffix: '14',
    planStatus: 2,
    alertStatus: 0,
    createdBy: 'lipan',
    updatedBy: 'lipan',
    createdAt: '2024-05-30 17:54:57',
    updatedAt: '2024-05-30 18:08:07',
    viewStatus: 1,
    startTimeLocalDate: '2024-09-30',
    endTimeLocalDate: '2024-10-01',
    rankDatas: [null],
  },
];

const mock2 = [
  {
    rankDate: '2024-09-16',
    rankValue: null,
    activityId: null,
    activity: null,
    rankDataList: [
      {
        activityId: 'SZKFCDY2408097',
        activity: '【抖音】中秋花灯桶三人餐兑换券',
      },
      {
        activityId: 'SZKFCMT2408186',
        activity: '【美团】中秋花灯桶三人餐兑换券',
      },
      {
        activityId: 'SMY20230246379_10010',
        activity: '29.9元超值三件套单人餐兑换券',
      },
      {
        activityId: 'SZKFCDY2408117',
        activity: '【抖音】6份吮指原味鸡/黄金脆皮鸡兑换券',
      },
      {
        activityId: 'SZKFCDY2408096',
        activity: '【抖音】中秋花灯桶双人餐兑换券',
      },
    ],
  },
  {
    rankDate: '2024-09-15',
    rankValue: null,
    activityId: null,
    activity: null,
    rankDataList: [
      {
        activityId: 'SZKFCDY2406142',
        activity: '【抖音】周末疯狂拼9件随心选兑换券',
      },
      {
        activityId: 'SMY20230246380_10010',
        activity: '19.9元超值两件套单人餐A兑换券',
      },
      {
        activityId: 'SZKFCDY2408097',
        activity: '【抖音】中秋花灯桶三人餐兑换券',
      },
      {
        activityId: 'SZKFCDY2406141',
        activity: '周末疯狂拼 4件随心选兑换券',
      },
      {
        activityId: 'SZKFCMT2408186',
        activity: '【美团】中秋花灯桶三人餐兑换券',
      },
    ],
  },
  {
    rankDate: '2024-09-14',
    rankValue: null,
    activityId: null,
    activity: null,
    rankDataList: [
      {
        activityId: 'SMY20231251122_10010',
        activity: '甜咸搭配小食两件套兑换券',
      },
      {
        activityId: 'SMY20230246380_10010',
        activity: '19.9元超值两件套单人餐A兑换券',
      },
      {
        activityId: 'SZKFCDY2406142',
        activity: '【抖音】周末疯狂拼9件随心选兑换券',
      },
      {
        activityId: 'SZKFCDY2408117',
        activity: '【抖音】6份吮指原味鸡/黄金脆皮鸡兑换券',
      },
      {
        activityId: 'SZKFCDY2406141',
        activity: '周末疯狂拼 4件随心选兑换券',
      },
    ],
  },
  {
    rankDate: '2024-09-13',
    rankValue: null,
    activityId: null,
    activity: null,
    rankDataList: [
      {
        activityId: 'SMY20231251122_10010',
        activity: '甜咸搭配小食两件套兑换券',
      },
      {
        activityId: 'SZKFCDY2408067',
        activity: '【抖音】2份原味鸡汉堡/香辣鸡腿堡兑换券',
      },
      {
        activityId: 'SZKFCDY2408082',
        activity: '【抖音】2只葡式蛋挞兑换券',
      },
      {
        activityId: 'SZKFC2406267',
        activity: '经典主食（3选1）买一送一优惠券',
      },
      {
        activityId: 'SZKFC2406268',
        activity: '经典小食（4选1）买一送一优惠券',
      },
    ],
  },
  {
    rankDate: '2024-09-12',
    rankValue: null,
    activityId: null,
    activity: null,
    rankDataList: [
      {
        activityId: 'SZKFCDY2408091',
        activity: '【抖音】中秋花灯桶三人餐兑换券',
      },
      {
        activityId: 'SMY20231251122_10010',
        activity: '甜咸搭配小食两件套兑换券',
      },
      {
        activityId: 'SZKFCMT2408156',
        activity: '主食随心选OK三件套兑换券',
      },
      {
        activityId: 'SZKFCDY2408062',
        activity: '【抖音】主食随心选OK三件套兑换券',
      },
      {
        activityId: 'SZKFCMT2408177',
        activity: '【美团】中秋花灯桶三人餐兑换券',
      },
    ],
  },
  {
    rankDate: '2024-09-11',
    rankValue: null,
    activityId: null,
    activity: null,
    rankDataList: [
      {
        activityId: 'SZKFCDY2408067',
        activity: '【抖音】2份原味鸡汉堡/香辣鸡腿堡兑换券',
      },
      {
        activityId: 'SZKFC2406267',
        activity: '经典主食（3选1）买一送一优惠券',
      },
      {
        activityId: 'SZKFCDY2408082',
        activity: '【抖音】2只葡式蛋挞兑换券',
      },
      {
        activityId: 'SZKFC2406268',
        activity: '经典小食（4选1）买一送一优惠券',
      },
      {
        activityId: 'SMY20231251122_10010',
        activity: '甜咸搭配小食两件套兑换券',
      },
    ],
  },
  {
    rankDate: '2024-09-10',
    rankValue: null,
    activityId: null,
    activity: null,
    rankDataList: [
      {
        activityId: 'SZKFCDY2408082',
        activity: '【抖音】2只葡式蛋挞兑换券',
      },
      {
        activityId: 'SZKFC2406267',
        activity: '经典主食（3选1）买一送一优惠券',
      },
      {
        activityId: 'SZKFCDY2408067',
        activity: '【抖音】2份原味鸡汉堡/香辣鸡腿堡兑换券',
      },
      {
        activityId: 'SZKFC2406268',
        activity: '经典小食（4选1）买一送一优惠券',
      },
      {
        activityId: 'SZKFCMT2408154',
        activity: '【美团】2份原味鸡汉堡/香辣鸡腿堡兑换券',
      },
    ],
  },
  {
    rankDate: '2024-09-09',
    rankValue: null,
    activityId: null,
    activity: null,
    rankDataList: [
      {
        activityId: 'SZKFCDY2408082',
        activity: '【抖音】2只葡式蛋挞兑换券',
      },
      {
        activityId: 'SZKFCDY2408067',
        activity: '【抖音】2份原味鸡汉堡/香辣鸡腿堡兑换券',
      },
      {
        activityId: 'SZKFC2406267',
        activity: '经典主食（3选1）买一送一优惠券',
      },
      {
        activityId: 'SZKFC2406268',
        activity: '经典小食（4选1）买一送一优惠券',
      },
      {
        activityId: 'SMY20231251122_10010',
        activity: '甜咸搭配小食两件套兑换券',
      },
    ],
  },
  {
    rankDate: '2024-09-08',
    rankValue: null,
    activityId: null,
    activity: null,
    rankDataList: [
      {
        activityId: 'SZKFCDY2406142',
        activity: '【抖音】周末疯狂拼9件随心选兑换券',
      },
      {
        activityId: 'SZKFCDY2406141',
        activity: '周末疯狂拼 4件随心选兑换券',
      },
      {
        activityId: 'SMY20230246380_10010',
        activity: '19.9元超值两件套单人餐A兑换券',
      },
      {
        activityId: 'SZKFCDY2408087',
        activity: '【抖音】 缤纷吃鸡三人餐兑换券',
      },
      {
        activityId: 'SMY20231251122_10010',
        activity: '甜咸搭配小食两件套兑换券',
      },
    ],
  },
  {
    rankDate: '2024-09-07',
    rankValue: null,
    activityId: null,
    activity: null,
    rankDataList: [
      {
        activityId: 'SMY20231251122_10010',
        activity: '甜咸搭配小食两件套兑换券',
      },
      {
        activityId: 'SZKFCDY2406142',
        activity: '【抖音】周末疯狂拼9件随心选兑换券',
      },
      {
        activityId: 'SZKFCDY2408087',
        activity: '【抖音】 缤纷吃鸡三人餐兑换券',
      },
      {
        activityId: 'SZKFCDY2408066',
        activity: '【抖音】间谍过家家玩具套餐兑换券',
      },
      {
        activityId: 'SZKFCDY2406141',
        activity: '周末疯狂拼 4件随心选兑换券',
      },
    ],
  },
  {
    rankDate: '2024-09-06',
    rankValue: null,
    activityId: null,
    activity: null,
    rankDataList: [
      {
        activityId: 'SZKFCDY2408066',
        activity: '【抖音】间谍过家家玩具套餐兑换券',
      },
      {
        activityId: 'SZKFCDY2408068',
        activity: '【抖音】2份吮指原味鸡/黄金鸡块兑换券',
      },
      {
        activityId: 'SZKFCDY2408067',
        activity: '【抖音】2份原味鸡汉堡/香辣鸡腿堡兑换券',
      },
      {
        activityId: 'SZKFC2406265',
        activity: '经典主食（3选1）买一送一优惠券',
      },
      {
        activityId: 'SZKFC2406266',
        activity: '经典小食（4选1）买一送一优惠券',
      },
    ],
  },
  {
    rankDate: '2024-09-05',
    rankValue: null,
    activityId: null,
    activity: null,
    rankDataList: [
      {
        activityId: 'SMY20231251122_10010',
        activity: '甜咸搭配小食两件套兑换券',
      },
      {
        activityId: 'SZKFCDY2408089',
        activity: '【抖音】心动堡堡双人餐兑换券',
      },
      {
        activityId: 'SZKFCMT2408156',
        activity: '主食随心选OK三件套兑换券',
      },
      {
        activityId: 'SMK20240552164_10000',
        activity: '【30天吃2顿】打工人随心选6件套兑换券',
      },
      {
        activityId: 'SZKFCDY2404091',
        activity: '吃鸡星人狂喜三人餐兑换券',
      },
    ],
  },
  {
    rankDate: '2024-09-04',
    rankValue: null,
    activityId: null,
    activity: null,
    rankDataList: [
      {
        activityId: 'SZKFCDY2408068',
        activity: '【抖音】2份吮指原味鸡/黄金鸡块兑换券',
      },
      {
        activityId: 'SZKFCDY2408067',
        activity: '【抖音】2份原味鸡汉堡/香辣鸡腿堡兑换券',
      },
      {
        activityId: 'SZKFC2406265',
        activity: '经典主食（3选1）买一送一优惠券',
      },
      {
        activityId: 'SZKFC2406266',
        activity: '经典小食（4选1）买一送一优惠券',
      },
      {
        activityId: 'SMY20231251122_10010',
        activity: '甜咸搭配小食两件套兑换券',
      },
    ],
  },
  {
    rankDate: '2024-09-03',
    rankValue: null,
    activityId: null,
    activity: null,
    rankDataList: [
      {
        activityId: 'SZKFCDY2408068',
        activity: '【抖音】2份吮指原味鸡/黄金鸡块兑换券',
      },
      {
        activityId: 'SZKFCDY2408067',
        activity: '【抖音】2份原味鸡汉堡/香辣鸡腿堡兑换券',
      },
      {
        activityId: 'SZKFC2406265',
        activity: '经典主食（3选1）买一送一优惠券',
      },
      {
        activityId: 'SZKFC2406266',
        activity: '经典小食（4选1）买一送一优惠券',
      },
      {
        activityId: 'SMY20231251122_10010',
        activity: '甜咸搭配小食两件套兑换券',
      },
    ],
  },
  {
    rankDate: '2024-09-02',
    rankValue: null,
    activityId: null,
    activity: null,
    rankDataList: [
      {
        activityId: 'SZKFCDY2408068',
        activity: '【抖音】2份吮指原味鸡/黄金鸡块兑换券',
      },
      {
        activityId: 'SZKFCDY2408067',
        activity: '【抖音】2份原味鸡汉堡/香辣鸡腿堡兑换券',
      },
      {
        activityId: 'SZKFC2406265',
        activity: '经典主食（3选1）买一送一优惠券',
      },
      {
        activityId: 'SMY20231251122_10010',
        activity: '甜咸搭配小食两件套兑换券',
      },
      {
        activityId: 'SZKFC2406266',
        activity: '经典小食（4选1）买一送一优惠券',
      },
    ],
  },
  {
    rankDate: '2024-09-01',
    rankValue: null,
    activityId: null,
    activity: null,
    rankDataList: [
      {
        activityId: 'SMY20231251122_10010',
        activity: '甜咸搭配小食两件套兑换券',
      },
      {
        activityId: 'SZKFCDY2406142',
        activity: '【抖音】周末疯狂拼9件随心选兑换券',
      },
      {
        activityId: 'SMY20230246380_10010',
        activity: '19.9元超值两件套单人餐A兑换券',
      },
      {
        activityId: 'SZKFCDY2406141',
        activity: '周末疯狂拼 4件随心选兑换券',
      },
      {
        activityId: 'SZKFCDY2408019',
        activity: '【抖音】 暑期"冰"纷三人餐兑换券',
      },
    ],
  },
];

const MyCalendar: React.FC = () => {
  const fullCalendarRef = useRef<any>(null);
  // const [date, setDate] = useState(new Date()); // 日历的头部日期
  const [date, setDate] = useState('2024-09-01'); // 日历的头部日期
  const [queryForm] = Form.useForm(); // 筛选条件
  const [segmentValue, setSegmentValue] = useState('1'); // 日历的头部---tab
  const [spinning, setSpinning] = useState(false);
  const [modelVisible, setModelVisible] = useState(false);
  const [initialEvent, setInitialEvent] = useState([]); // 事件总数据
  const [initialActivity, setInitialActivity] = useState([]); // 活动总数据

  const getViewSearchData = async () => {
    const formValues = queryForm.getFieldsValue();
    // 获取月份第一天
    const firstDayOfMonth = moment(date).startOf('month');
    // 获取月份最后一天
    const lastDayOfMonth = moment(date).endOf('month');

    const param: any = {
      ...formValues,
      startTime: firstDayOfMonth.format('YYYY-MM-DD'),
      endTime: lastDayOfMonth.format('YYYY-MM-DD'),
    };
    // param.startTime = firstDayOfMonth.format('YYYY-MM-DD');
    if (segmentValue !== '1') {
      param.channelId = segmentValue === '2' ? 'CPOS' : 'Delivery';
    }

    if (segmentValue === '1') {
      mock1.forEach((item: any) => {
        item.paramId = item.id;
        item.id = uuidV4();
        item.title = item.planName;
        item.name = item.planName;
        item.start = item.startTimeLocalDate;
        item.end = item.endTimeLocalDate;
        item.flagTime = item.endTime;
        item.backgroundColor = '#fff';
        item.borderColor = '#fff';
      });
      // @ts-ignore
      setInitialEvent(mock1);
      setInitialActivity([]);
    } else {
      // @ts-ignore
      setInitialActivity(mock2);
      setInitialEvent([]);
    }

    // const fetchApi = segmentValue === '1' ? planViewSearch : activityViewSearch;

    // setSpinning(true);
    // const { code, data } = await fetchApi(param);
    // setSpinning(false);
    // if (code === 200 && data) {
    //   if (segmentValue === '1') {
    //     data.forEach((item: any) => {
    //       item.paramId = item.id;
    //       item.id = uuidV4();
    //       item.title = item.planName;
    //       item.name = item.planName;
    //       item.start = item.startTimeLocalDate;
    //       item.end = item.endTimeLocalDate;
    //       item.flagTime = item.endTime;
    //       item.backgroundColor = '#fff';
    //       item.borderColor = '#fff';
    //     });
    //     setInitialEvent(data);
    //     setInitialActivity([]);
    //   } else {
    //     setInitialActivity(data);
    //     setInitialEvent([]);
    //   }
    // }
  };

  useEffect(() => {
    getViewSearchData();
    const calendarApi = fullCalendarRef.current!.getApi();
    calendarApi.getDate();
  }, [date, segmentValue]);

  /**
  / 切换时间月份
   */
  const handleMove = (action: HandleMoveArg) => {
    const calendarApi = fullCalendarRef.current!.getApi();
    console.log('哥哥哥', calendarApi);

    switch (action) {
      case 'nextYear':
        calendarApi.nextYear();
        break;
      case 'prevYear':
        calendarApi.prevYear();
        break;
      case 'prev':
        calendarApi.prev();
        break;
      case 'next':
        calendarApi.next();
        break;
      case 'today':
        calendarApi.today();
        break;
      default:
        break;
    }
    setDate(calendarApi.getDate());
  };

  // 查询--接口
  const handleQuey = () => {
    getViewSearchData();
  };

  const resetForm = () => {
    queryForm.resetFields();
  };

  const handleRefresh = async () => {
    // setSpinning(true);
    // const { code } = await resetCache({});
    // if (code === 200) {
    //   getViewSearchData();
    // } else {
    //   setSpinning(false);
    // }
  };

  return (
    <div className={styles['rili-body']}>
      <div className={styles['query-body']}>
        <Form
          labelCol={{ span: 8 }}
          form={queryForm}
          initialValues={{
            activityId: '',
            planName: '',
          }}
        >
          <div style={{ display: 'flex' }}>
            <Form.Item label="2024-10-15活动定义" name="activityId" style={{ width: 300 }}>
              <Input />
            </Form.Item>
            <Form.Item label="计划名称" name="planName" style={{ width: 300 }}>
              <Input />
            </Form.Item>
          </div>
        </Form>
        <div
          style={{
            display: 'flex',
          }}
        >
          <Button style={{ marginLeft: 20 }} onClick={resetForm}>
            重置
          </Button>
          <Button style={{ marginLeft: 20 }} type="primary" onClick={handleQuey}>
            查询
          </Button>
          <Button style={{ marginLeft: 20 }} type="primary" onClick={handleRefresh}>
            刷新缓存
          </Button>
          <Button
            style={{ marginLeft: 20 }}
            type="primary"
            onClick={() => {
              setModelVisible(true);
              setTimeout(() => {
                setModelVisible(false);
              });
            }}
          >
            活动导出
          </Button>
        </div>
      </div>
      <div className={styles['calendar-warp']}>
        {/* 日历头组件 */}
        <CalendarHeader
          now={date}
          onMove={handleMove}
          segmentValue={segmentValue}
          setSegmentValue={setSegmentValue}
        />
        {/* 日历渲染组件 */}
        <Spin spinning={spinning}>
          <CalendarBody
            fullCalendarRef={fullCalendarRef}
            segmentValue={segmentValue}
            initialEvent={initialEvent}
            initialActivity={initialActivity}
            getViewSearchData={getViewSearchData}
          />
        </Spin>
        {/* 导出文件弹窗 */}
        {/* <ModelOutput modelVisible={modelVisible} /> */}
      </div>
    </div>
  );
};

export default MyCalendar;
